<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
 String no =request.getParameter("no");
 try {
	Class.forName("com.mysql.jdbc.Driver");
	Connection con= DriverManager.getConnection("jdbc:mysql://localhost:3306/stu", "root", "root");//获得数据库连接
	PreparedStatement st =con.prepareStatement("select * from student where sno=?");
	st.setString(1, no);
	ResultSet rs = st.executeQuery();
	rs.next();//rs往下移动指向第一条记录
	String sno= rs.getString("sno");
	String sdep=rs.getString("sdep");
	String ssex= rs.getString("ssex");
	int sage= rs.getInt("sage");
	String sname= rs.getString("sname");
	rs.close();
	st.close();
	con.close();
%>
<form action="updateinfo.jsp"  method="post">
   <fieldset>
      <legend>修改信息</legend>
      <label>学号:<input type="text" name="sno" value="<%=sno%>" readonly="readonly"></label><br>
      <label>院系:<select name="sdep">
                 <option value="计算机科学系" <%if(sdep.equals("计算机科学系")){ %>selected="selected" <%} %>>计算机科学系</option>
      			<option value="外语系" <%if(sdep.equals("外语系")){ %>selected="selected" <%} %>>外语系</option>
      			<option value="化工系" <%if(sdep.equals("化工系")){ %>selected="selected" <%} %>>化工系</option>
      			<option value="机械工程系" <%if(sdep.equals("机械工程系")){ %>selected="selected" <%} %>>机械工程系</option>
      			</select>
      </label><br>
      <label>性别:<input type="radio" name="ssex" value="男" <%if(ssex.equals("男")){%>checked="checked" <%} %>>男
             <input type="radio" name="ssex" value="女" <%if(ssex.equals("女")){ %>checked="checked" <%} %>>女
      </label><br>
      <label>年龄:<input type="text" name="sage" value="<%=sage%>"></label><br>
      <label>姓名:<input type="text" name="sname" value="<%=sname%>"></label><br>
      <label><input type="submit" value="提交"></label>
   </fieldset>
</form>
<%}catch(Exception e){
	 e.printStackTrace();
	}%>
</body>
</html>